<!-- 忘记密码 -->
<template>
	<view class="container">
		<!-- 背景图 -->
		<view class="x-c"><image class="logo-bg"  :src="$IMG_URL + '/imgs/logo_bg.png'" mode=""></image></view>
		<!-- titleview -->
		<view class="wrapper">
			<!-- logo -->
			<view class="x-c">
				<view class="tab-item x-c">
					<text class="tab-title">修改密码</text>
					<view class="line-box"><text class="triangle"></text></view>
				</view>
			</view>
			<!-- 表单 -->
			<view class="login-box y-f">
				<view class="input-item x-c">
					<text class="inp-title">手机号</text>
					<input class="inp" v-model="userPhone" type="number" placeholder="请输入手机号" placeholder-class="pl" />
				</view>
				<view class="input-item x-c">
					<text class="inp-title">旧密码</text>
					<input class="inp" password v-model="userPassword" type="text" placeholder="请设置新密码" placeholder-class="pl" />
				</view>
				<view class="input-item x-c">
					<text class="inp-title">新密码</text>
					<input class="inp" password v-model="userPasswordTwo" type="text" placeholder="请设置新密码" placeholder-class="pl" />
				</view>
			</view>
			<!-- 登录按钮 -->
			<view class="x-c y-f">
				<button class="cu-btn login-btn mb30 bg-blue radius" @tap="restPassword">确认</button>
				<button class="cu-btn tip-btn" @tap="jump('/pages/public/login')">返回登录</button>
			</view>
		</view>
	</view>
</template>

<script>

export default {
	data() {
		return {
			code: {
				text: '获取验证码',
				status: false,
				value: ''
			},
			userPhone: '',
			userPassword: '',
			userPasswordTwo:'',
			sysInfo: uni.getStorageSync('sysInfo')
		};
	},
	onLoad() {},
	methods: {
		// 路由跳转
		jump(path){
			uni.navigateTo({
				url: path
			})
		},
		// 重置密码
		restPassword() {
			let that = this;
			uni.request({
				url: '',
				data: {
					userPhone: this.userPhone,
					userPassword:this.userPassword,
					userPasswordTwo:this.userPasswordTwo,
				},
				method: 'POST',
				success: (res) => {
					if (res.code === 1) {
						const userdata = res.data.data
						userinfo_check.userdata = userdata
						uni.setStorageSync('userinfo', userinfo_check)
						uni.showToast({
							title: res.msg || '修改密码成功,请前往登录',
							duration: 2000,
							icon: 'none'
						});
						uni.removeStorageSync('userinfo');
						setTimeout(function() {
							uni.navigateTo({
								url: '/pages/public/login',
							});
						}, 1500)
					}
				},
				fail: (err) => {
			
				}
			});
		}
	}
};
</script>

<style lang="scss">
.container {
	position: relative;
	width: 100vw;
	height: 100vh;
	background: #FFFFFF;

	// titleview
	.head-box {
		.cuIcon-back {
			font-size: 50rpx !important;
			font-weight: 500;
		}
	}

	// logo
	.logo {
		width: 410rpx;
		height: 120rpx;
	}

	.logo-bg {
		width: 640rpx;
		height: 300rpx;
	}
	// 标题
	.tab-item {
		flex: 1;
		height: 80rpx;
		position: relative;
		margin-top: 80rpx;
		.tab-title {
			font-size: 32rpx;
			font-weight: bold;
			color: #333;
		}

		.line-box {
			position: absolute;
			width: 300rpx;
			height: 4rpx;
			background: #bbb;
			bottom: 0;
			left: 50%;
			transform: translateX(-50%);

			.triangle {
				position: absolute;
				bottom: 0;
				left: 50%;
				transform: translateX(-50%);
				disply: block;
				width: 0;
				height: 0;
				border-width: 10rpx;
				border-style: solid;
				border-color: transparent transparent #bbb transparent;
			}
		}
	}
}

.wrapper {
	position: absolute;
	z-index: 90;
	padding-bottom: 40upx;
	padding-top: 20px;
	width: 100vw;
	height: 100vh;
	top: 0;

	// 输入
	.login-box {
		margin-top: 80rpx;
		.input-item {
			height: 108rpx;
			border-bottom: 2rpx solid rgba(#ddd, 0.3);
			width: 608rpx;

			.inp-title {
				font-size: 30rpx;
				// color: #999;
				padding-right: 30rpx;
			}

			.inp {
				flex: 1;
				height: 100%;
				font-size: 28rpx;
			}

			.pl {
				color: #999;
			}

		}
	}

	// 登录
	.login-btn {
		width: 630upx;
		height: 80upx;
		// border-radius: 20rpx;
		margin-top: 70upx;
		color: #fff;
	}

	.tip-btn {
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 400;
		text-decoration: underline;
		color: #333;
		background: none;
	}
}
</style>
